package com.peng.controller;

import com.peng.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ControllerDome {

    @RequestMapping("a1")
    @ResponseBody
    public String ajax(String name1){
        if ("kuangshen".equals(name1))
            return "true";
        else
        return "false";
    }

    @RequestMapping("a2")
    @ResponseBody
    public List<User> ajax2(){
        ArrayList<User> objects = new ArrayList<User>();
        objects.add(new User("张某",2));
        objects.add(new User("liu某",2));
        objects.add(new User("chi某",2));
        return objects;
    }

    @RequestMapping("a3")
    @ResponseBody
    public String ajax3(String name,String pwd){
        String msg = "";
        if (name!=null){
            if (name.equals("admin"))
                msg="OK";
            else msg="用户名有误";
        }
        if (pwd!=null){
            if (pwd.equals("123"))
                msg="OK";
            else msg="密码有误";
        }
        return msg;
    }
}
